<div class="portlet">
    <div class="portlet-actions">
        <button class="btn blue btn-sm" ng-click="grid.add()"><i class="fa fa-plus"></i> 新增</button>
    </div>
    <form class="portlet-search-body" name="queryForm">
        <input type="text" class="form-control search-item" ng-model="refundName" placeholder="名称">
        <select class="form-control search-item search-item-expand" ng-model="refundType" ng-options="opt.value as opt.name for opt in options.refundtype">
            <option value=""  disabled selected hidden>-- 类型 --</option>
        </select>

        <div class="search-item">
            <button class="btn btn-icon-only default"><i class="fa fa-chevron-right"></i></button>
            <button class="btn btn-sm query" ng-click="grid.query();"><i class="fa fa-search"></i> 查询</button>
            <button class="btn btn-sm reset" ng-click="grid.reset();"><i class="fa fa-eraser"></i> 重置</button>
        </div>
    </form>
    <div class="portlet-body">
        <table ed-grid class="table table-striped table-bordered table-advance table-hover"
               data-options="url: 'refund/query.do', modelText: '退款方案', form: 'queryForm', modal: 'modal'">
            <thead>
            <tr>
                <th data-options="field: '_index'"></th>
                <th data-options="field: 'refundName'">名称</th>
                <th data-options="field: 'refundType | code : refundtype'">类型</th>
                <th data-options="field: 'minimumFee'">最低手续费</th>
                <th data-options="field: 'remark'">备注</th>
                <th>操作</th>
            </tr>
            </thead>
        </table>
    </div>
</div>

<!--弹出窗口：type （1：新增，2：修改，3：查看，4：编辑详情） -->
<div ed-modal="modal" data-options="title: '退款方案', static: true, width: 720, defaultButton:false,onHidden:'reset'">
    <form action="#" class="form-horizontal w5c-form" w5c-form-validate novalidate name="validateForm">

        <div class="form-body">
            <div class="form-group">
                <label class="col-md-2 control-label">名称</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" name="refundName" ng-model="refund.refundName" ng-disabled="type==3" required>
                </div>

                <label class="col-md-2 control-label">类型</label>
                <div class="col-md-4">
                    <select class="form-control" name="refundType" ng-model="refund.refundType"
                            ng-options="opt.value as opt.name for opt in options.refundtype" ng-disabled="type==3" required>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label">最低手续费</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" ng-model="refund.minimumFee" ng-disabled="type==3">
                </div>

                <label class="col-md-2 control-label">备注</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" ng-model="refund.remark" ng-disabled="type==3">
                </div>
            </div>

            <div class="card">
                <div class="card-header">
                    <h4>方案详情</h4>
                    <button ng-show="type != '3' && !(refund.refundType == '2' && refund.refundDetails.length > 0)" type="button" class="btn blue btn-sm" ng-click="grid.addDetail()"><i class="fa fa-plus"></i> 添加</button>
                </div>
                <div class="card-item" ng-repeat="refundDetail in refund.refundDetails">
                    <i ng-show="type != '3'"  class="glyphicon glyphicon-trash delete" ng-click="grid.deleteDetail($index)"></i>

                    <div class="form-group" ng-show="!refund.refundType || refund.refundType == '1'">
                        <label class="col-md-2 control-label" style="padding-right: 8px;padding-left: 5px;"><span class="required">*</span>提前时间(分钟)</label>
                        <div class="col-md-4">
                            <input type="text" class="form-control" name="minutes" ng-model="refundDetail.minutes" ng-disabled="type == '3'" >
                        </div>
                        <label class="col-md-2 control-label"><span class="required">*</span>费率</label>
                        <div class="col-md-4">
                            <input type="text" class="form-control" name="refundRate" ng-model="refundDetail.refundRate" ng-disabled="type == '3'">
                        </div>
                    </div>

                    <div class="form-group" ng-show="refund.refundType == '2'">
                        <label class="col-md-2 control-label" style="padding-right: 8px;padding-left: 5px;"><span class="required">*</span>固定费用(元)</label>
                        <div class="col-md-4">
                            <input type="text" class="form-control" name="fixedFee"
                                   ng-model="refundDetail.fixedFee" ng-disabled="type == '3'">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label"><span class="required">*</span>状态</label>
                        <div class="col-md-4">
                            <select class="form-control" name="refundType" ng-model="refundDetail.refundDetailStatus"
                                    ng-disabled="type == '3'" ng-options="opt.value as opt.name for opt in options.plandetailstatus" >
                            </select>
                        </div>
                        <label class="col-md-2 control-label">备注</label>
                        <div class="col-md-4">
                            <input type="text" class="form-control" ng-model="refundDetail.remark" ng-disabled="type == '3'">
                        </div>
                    </div>
                </div>
            </div>

        </div>

        <div class="form-actions">
            <button type="button" class="btn blue" w5c-form-submit="grid.save()" ng-if="type!=3">
                <i class="fa fa-save"></i> 保存
            </button>
            <button type="button" class="btn default" ng-click="grid.cancel();" ng-if="type!=3">
                <i class="fa fa-times"></i> 取消
            </button>
            <button type="button" class="btn blue" ng-click="grid.cancel();" ng-if="type==3">
                <i class="fa fa-times"></i> 确定
            </button>
        </div>
    </form>
</div>
